package com.lumyc.criteria;

import java.util.ArrayList;
import java.util.List;

public class CriteriaSingle implements Criteria {
    @Override
    public List<Person> meetCriteria(List<Person> persons) {
        //定义单身数组
        List<Person> singlePersons = new ArrayList<>();

        //遍历参数数组
        for (Person person : persons ) {
            //如果婚姻状态为单身则加入单身数组
            if(person.getMaritalStatus().equalsIgnoreCase("single")){
                singlePersons.add(person);
            }
        }

        //返回单身数组
        return singlePersons;
    }
}
